package demo3;

import java.util.Scanner;

public class Practise4 {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        Long n = in.nextLong();
        Long input = in.nextLong();
        Long max,min;
        max = min = input;
        for (int i = 1; i < n; i++) {
            input = in.nextLong();
            if(input > max) {
                max = input;
            }
            if(input < min)  {
                min = input;
            }
        }
        System.out.println(max + min);
    }
}